
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="CloudStorage.*" %>
<%
            int size = 0;
            if (session.getAttribute("cart") != null) {
                size = ((Cart) session.getAttribute("cart")).getSize();
            }
%>

<html>
    <head>
        <title>Cloud Share - My Account</title>
        <link rel="SHORTCUT ICON" href="images/eys.ico" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="style.css" />
        <link rel="stylesheet" type="text/css" href="account_style.css" />
        <script language="javascript">
            <!--

            var state = 'none';

            function showhide(layer_ref) {

                if (state == 'block') {
                    state = 'none';
                }
                else {
                    state = 'block';
                }
                if (document.all) { //IS IE 4 or 5 (or 6 beta)
                    eval( "document.all." + layer_ref + ".style.display = state");
                }
                if (document.layers) { //IS NETSCAPE 4 or below
                    document.layers[layer_ref].display = state;
                }
                if (document.getElementById &&!document.all) {
                    hza = document.getElementById(layer_ref);
                    hza.style.display = state;
                }
            }
            //-->
        </script>
        <style type="text/css">
            <!--
            #main .inside .block1 {
                text-align: left;
                clear: none;
                float: left;
                margin-left: 250px;
                height: 200px;
            }

            a:link {
                color: #F6F1F0;
                text-decoration: none;
            }
            a:visited {
                text-decoration: none;
            }
            a:hover {
                text-decoration: none;
            }
            a:active {
                text-decoration: none;
            }

            body,td,th {
                color: #64584C;
            }
            .load_bar {
                background-color:silver;
                padding: 5px;
                margin:2px;
                border:1px;
                border-color: buttonshadow;
            }
            #user_info{
	line-height: 24px;
            }
            -->
        </style>
    </head>

    <body>
        <div id="header">
            <div class="inside"> <a href="#" class="logo"><img src="images/logo2.gif" alt="" width="131" height="83" /></a>
                <p class="slogan">Share on Clouds!</p>
                <div id="cart">
                    <ul>
                        <li><a href="downloadcart.jsp"><img alt="cart" src="images/cart.png">  Download Cart (<%=size%>)</a> </li>
                    </ul>
                </div>
                <a href="faq.jsp" class="rss"><img src="images/rss.jpg" alt="" width="39" height="41" /></a>
            </div>
            <div id="menu">
               <% if (session.getAttribute("status") == null) {%>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="login.jsp"><img src="images/but_login.jpg" alt="" width="147" height="40" /></a></li>
                    <li><a href="register.jsp"><img src="images/but_reg.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>
                    
                </ul>
				<% } else { %>
                <ul>
                    <li><a href="index.jsp"><img src="images/but_home.jpg" alt="" width="148" height="40" /></a></li>
                    <li><a href="account.jsp"><img src="images/but_account.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="downloads.jsp"><img src="images/but_down.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="upload.jsp"><img src="images/but_upload.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="buy.jsp"><img src="images/but_buy.jpg" alt="" width="146" height="40" /></a></li>
                    <li><a href="LogoutServlet"><img src="images/but_logout.jpg" alt="" width="147" height="40" /></a></li>
                </ul>
                <%}%>
                
            </div>
            <div class="headimage">
                <img src="images/picture.jpg" alt="" /> </div>
        </div>
        <div class="inside">
        </div>
        <div id="main">
            <%
                        if (session.getAttribute("status") != null) {
            %>
            <div class="inside">
                <div id="cpanel">
                    <h1><img src="images/cpanel.png" width="40" height="20">User panel</h1>
                    <ul>
                        <li></li>
                        <li><img src="images/myaccount-icon.png" width="20" height="20"> <a href="account.jsp">My Account</a></li>
                        <li><img src="images/uploads_icon.png" width="20" height="20" ><a href="myuploads.jsp"> My Uploads</a></li>
                        <li><img src="images/uploadicon.png"><a href="upload.jsp"> Upload File</a></li>
                        <li><img src="images/cart.png" width="20" height="20"><a href="downloadcart.jsp"> Download Cart</a></li>
                        <li><img src="images/buy_icon.png" alt="" width="20" height="20"><a href="buy.jsp">Buy more Space</a></li>
                    </ul>
                    <span><a href="LogoutServlet"> <img src="images/logout.png"/></a></span>
                </div>
                <div id="blocks">
                    <div class="upload">

                        <% Database database = new Database();
                      
                        User logged_user = (User) session.getAttribute("user");
                       String username = logged_user.getUsername();
                                                
                                %>
                        <h3>My Account - <%= username %></h3>
                        <div id="upload-img"><img src="images/myaccount.png" width="128" height="128"></div>
                        <div id="upload-text">
                            <div id="advanced" >
                                <table width="110%" height="100" id="user_info">
                                    <tr>
                                        <td >Name</td>
                                        <td><%= logged_user.getName() %></td>
                                        <td >&nbsp;</td>
                                        <td>&nbsp;</td>
                                    </tr>

                                    <tr>
                                        <td>Surname</td>
                                        <td><%= logged_user.getSurname() %></td>
                                        <td >&nbsp;</td>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>E-mail</td>
                                        <td><%= logged_user.getEmail() %></td>
                                        <td ><a href="changemail.jsp">Change E-mail</a></td>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td>Username</td>
                                        <td><%= username %></td>
                                        <td><a href="changepassword.jsp">Change password</a></td>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr> <td>
                                           Storage Used</td>
                                        
                                            <%
                                             java.io.File dir = new java.io.File(username);
                                             if(logged_user.getAvailableSpace()!=0)
                                             {
                                             %>
                                             <td class="load_bar">
                                            <img src="./images/bar.png"  width="
                                            <%=((float) logged_user.getUsedSpace(dir) / (logged_user.getAvailableSpace() + logged_user.getUsedSpace(dir))) * 100%>%"/> </td>
                                        <td><%= ((float) logged_user.getUsedSpace(dir) / (logged_user.getAvailableSpace() + logged_user.getUsedSpace(dir))) * 100  %> %</td>
                                           <%}else {%>
                                           <td>You have not purchased any space yet!</td>
                                           <td><a href="buy.jsp">Buy some space here!</a></td>
                                        <%}%>
                                    </tr>

                                    <tr>
                                        <td>Files Uploaded</td>
                                        <td><%= database.getFilesOfUser(logged_user.getId()).size() %></td>
                                    </tr>
                                     <tr>
                                        <td>Directories</td>
                                        <td><%= database.getFilesOfUser(logged_user.getId()).size() %></td>
                                    </tr>
                                    <tr>
                                        <td>Total Space Paid</td>
                                        <td><%= (float) logged_user.getPaidSpace() / (1024 * 1024 * 1024) %> GB</td>
                                    </tr>
                                    <tr><td >Total Space Won</td>
                                        <td ><%= (float) logged_user.getBonusSpace() / (1024 * 1024) %> MB</td>
                                    </tr>
                                    <tr>
                                        <td >Free Space Remained</td>
                                        <td ><%= (float) logged_user.getAvailableSpace() / (1024 * 1024 * 1024) %> GB</td>
                                    </tr>
                                    <tr>
                                        <td>Total Credits Earned</td>
                                        <td><%= logged_user.getCredits()%></td>
                                    </tr>
                                    <tr>
                                        <td><a href="DeleteAccountServlet">Delete Account</a></td>
                                        <td>&nbsp;</td>
                                    </tr>
                                </table>
                                <p>&nbsp;</p>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <%} else {%>
            <p>You must be logged in in order to see this page!</p>
            <%}%>
        </div>
        <div id="footer">
            <div class="inside">
                <p>Cloud Share &copy; 2010   |  Webdesign by Panoylhs &amp; Roumdic S.A.</p>
            </div>
        </div>
    </body>
</html>
